// 检测传进来的对象中的每个属性是否都不为空null  undefined 空字符等；


//检测是否是数组

const emptyCheck = (object = Object, formatCheck = Object) => {
    let res = {
        code:0,
        msg: "check success"
    };
    const setRes = (code, msg) => {
        res={
            status:code,
            message:msg
        }
    }



    for (let key in object) {
        var val = object[key];
        if (val === "" || val === undefined || val === null) {
            res = {
                code: 100,
                msg: `${key}值为必填项`
            }
            // 终止for循环
            break;
        }

    }

    // 检查格式是否正确
    for (let key in formatCheck) {
        if (formatCheck[key]) {
            switch (formatCheck[key]) {
                case "Array": Array.isArray(object[key]) === false ?setRes("10000",`${formatCheck[key]}必须是数组`) : null;
                default:
            }

        }
    }

    return res;

}
module.exports = {
    emptyCheck
}